package leertaak2;
/**
 * This class contains all the data that is extracted
 * from the XML file and is inserted into the database
 * @author Marco Vellinga
 * @author Sander Wagenaar
 *
 */
public class Data {
	
	// Variables
	String stn;
	String date;
	String time;
	String temp;
	String dewp;
	String stp;
	String slp;
	String visib;
	String wdsp;
	String prcp;
	String sndp;
	String frshtt;
	String cldc;
	String wnddir;
	
	Reader reader;
	
	/**
	 * Constructor
	 */
	public Data(){
		
	}
	
	/**
	 * Function to check if a string is empty
	 * @param data
	 * @return
	 */
	public boolean checkEmpty(String data){
		if(data.length() == 0){
			return true;
		} else {
			return false;
		}
	}
	
	// Setters for the variables
	
	public void setStn(String stn){
		this.stn = stn;
		reader = new Reader(this.stn);
	}
	
	// 1
	public void setDate(String date){
		this.date = date;
	}
	
	// 2
	public void setTime(String time){
		this.time = time;
	}
	
	// 3
	public void setTemp(String temp){
		
		if(checkEmpty(temp)){
			this.temp = reader.extrapolatie(3);
		} else {
			this.temp = reader.extrapolatieTemp(temp);
		}
			
	}
	
	// 4
	public void setDewp(String dewp){
		
		if(checkEmpty(dewp.trim())){
			this.dewp = reader.extrapolatie(4);
		} else {
			this.dewp = dewp;
		}
	}
	
	// 5
	public void setStp(String stp){
		
		if(checkEmpty(stp.trim())){
			this.stp = reader.extrapolatie(5);
		} else {
			this.stp = stp;
		}
	}
	
    // 6
	public void setSlp(String slp){
		
		if(checkEmpty(slp.trim())){
			this.slp = reader.extrapolatie(6);
		} else {
			this.slp = slp;
		}
	}
	
	// 7
	public void setVisib(String visib){
		
		if(checkEmpty(visib.trim())){
			this.visib = reader.extrapolatie(7);
		} else {
			this.visib = visib;
		}
	}
	
	// 8
	public void setWdsp(String wdsp){
		
		if(checkEmpty(wdsp.trim())){
			this.wdsp = reader.extrapolatie(8);
		} else {
			this.wdsp = wdsp;
		}
	}
	
	// 9
	public void setPrcp(String prcp){
		
		if(checkEmpty(prcp.trim())){
			this.prcp = reader.extrapolatie(9);
		} else {
			this.prcp = prcp;
		}
	}
	
	// 10
	public void setSndp(String sndp){
		
		if(checkEmpty(sndp.trim())){
			this.sndp = reader.extrapolatie(10);
		} else {
			this.sndp = sndp;
		}
	}
	
	// 11
	public void setFrshtt(String frshtt){
		this.frshtt = frshtt;
	}
	
	// 12
	public void setCldc(String cldc){
		
		if(checkEmpty(cldc.trim())){
			this.cldc = reader.extrapolatie(12);
		} else {
			this.cldc = cldc;
		}
	}
	
	// 13
	public void setWnddir(String wnddir){
		
		if(checkEmpty(wnddir.trim())){
			this.wnddir = reader.extrapolatie(13);
		} else {
			this.wnddir = wnddir;
		}
	}
	
	// Getters for the variables
	
	public String getStn(){
		return stn;
	}
	
	public String getDate(){
		return date;
	}
	
	public String getTime(){
		return time;
	}

	public String getTemp(){
		return temp;
	}
	
	public String getDewp(){
		return dewp;
	}
	
	public String getStp(){
		return stp;
	}
	
	public String getSlp(){
		return slp;
	}
	
	public String getVisib(){
		return visib;
	}
	
	public String getWdsp(){
		return wdsp;
	}
	
	public String getPrcp(){
		return prcp;
	}
	
	public String getSndp(){
		return sndp;
	}
	
	public String getFrshtt(){
		return frshtt;
	}
	
	public String getCldc(){
		return cldc;
	}
	
	public String getWnddir(){
		return wnddir;
	}
}
